Data storage method and server applicable to distributed server cluster

ABSTRACT

Data may be stored in a distributed server cluster which includes a plurality of nodes. A specific implementation of a method for storing data in the distributed server cluster comprises: receiving a data write request, the data write request comprising to-be-written data; broadcasting the data write request to each of groups in the server cluster, the each of the groups comprising at least one node, and at least one of the groups comprising at least two nodes; and sending a notification message of successful writing to a client sending the data write request, in response to receiving a confirmation message fed back from more than a half of the groups.

CROSS-REFERENCE TO RELATED APPLICATION

This application is related to and claims priority from ChineseApplication No. 201710464719.4, filed on Jun. 19, 2017 and entitled“Data Storage Method and Server Applicable to Distributed ServerCluster”, the entire disclosure of which is hereby incorporated byreference.

TECHNICAL FIELD

The present disclosure relates to the field of computer technology,particularly to the field of database technology, and more particularlyto a data storage method and server applicable to a distributed servercluster.

BACKGROUND

With the rapid growth of Internet data, database as a storage medium forthe Internet data bears increasingly more responsibility for datastorage and data access. In a distributed data storage system, a givenpiece of data has multiple backups and is stored on different servers.Data consistency is an important indicator of Internet services. Dataconsistency, that is, multiple backups of the given data remainconsistent.

In the data consistency protocol adopted in the existing distributeddata storage schemas, data write is considered to be successful whendata is written to more than a half of the servers. However, the serverresource in the cluster is limited, and data consistency occupiesconsiderable server resource, resulting in lower service availability,which is not conducive to efficient processing of service requests.

SUMMARY

To solve one or more technical problems mentioned in the abovebackground section, embodiments of present disclosure provide a datastorage method and server applicable to the data server cluster.

According to a first aspect, the embodiments of the present disclosureprovide a data storage method applicable to the distributed servercluster, the server cluster including a plurality of nodes, and themethod comprising: a master node in the server cluster receives a datawrite request, the data write request comprising a to-be-written data;the master node broadcasts the data write request to each of groups inthe server cluster, the each of the groups including at least one node;the master node sends a notification message of successful writing tothe client sending the data write request, in response to receiving aconfirmation message fed back from more than a half of the groups;wherein, if the group does not comprise the master node, the group feedsback the confirmation message to the master node in response to at leastone of the nodes in the group writing the to-be-written data to a memorysuccessfully.

In some embodiments, if the group comprises the master node, the groupfeeds back a confirmation message to the master node in response to themaster node writing the to-be-written data into the memory successfully.

In some embodiments, if the group comprises the master node and at leastone slave node, the group feeds back the confirmation message to themaster node in response to the master node and the at least one slavenode in the group writing the to-be-written data to the memorysuccessfully.

In some embodiments, the above method further comprises: one of theslave nodes in the server cluster as a candidate node issues an electionrequest to each of the groups, in response to a number of the groupsfeeding back the confirmation message to the master node being less thana half, or none of the nodes in each of more than a half of the groupsreceiving a heartbeat message broadcasted by the master node within apreset time; the candidate node is switched as a new master node, inresponse to the candidate node receiving an agree message from each nodein the each of more than a half of the groups.

In some embodiments, the above method further comprises: dividing aplurality of nodes in the server cluster into a plurality of groupsaccording to a deployed physical location of each of the nodes.

In some embodiments, the above method further comprises: the master nodesends a data synchronization confirmation message to the each of thegroups feeding back the confirmation message, in response to receivingthe confirmation message fed back from more than a half of the groups.

According to a second aspect, the embodiments of the present disclosureprovide a data storage server applicable to a distributed data servercluster, including: a receiving unit, configured to receive a data writerequest, the data write request comprising the to-be-written data; abroadcasting unit, configured to broadcast the data write request to theeach of the groups in the server cluster, the each of the groupsincluding at least one node, and at least one of the groups including atleast two nodes; a sending unit, configured to send a notificationmessage of successful writing to a client sending the data writerequest, in response to receiving a confirmation message fed back frommore than a half of the groups; wherein, if a group does not comprisethe master node in the server cluster, the group feeds back theconfirmation message to the master node, in response to at least onenode in the group writing the to-be-written data to a memorysuccessfully.

In some embodiments, the above server further includes: a requestingunit, as a candidate node, configured to issue an election request tothe each of the groups, in response to a number of the groups feedingback the confirmation message to the master node being less than a half,or none of the nodes in each of more than a half of the groups receivinga heartbeat message broadcasted by the master node within a preset time;and a switching unit, configured to be switched as a new master node, inresponse to the candidate node receiving an agree message from each nodein the each of more than a half of the groups.

In some embodiments, the above server further includes: a confirmationunit, configured to send a data synchronization confirmation message tothe each of the groups feeding back the confirmation message in responseto receiving the confirmation message fed back from more than a half ofthe groups.

The present disclosure provides a data storage method and serverapplicable to the data server cluster: the master node in the servercluster receives the data write request; then the master node broadcaststhe data write request to each of the groups in the server cluster,wherein each of the groups includes at least one node. When the masternode receives a confirmation message fed back from more than a half ofthe groups, the master node sends a notification message of successfulwriting to the client sending the data write request; wherein, if thegroup does not include the master node, then the group feeds back aconfirmation message to the master node after at least one of the nodesin the group has written the to-be-written data successfully, leading todecreases of the number of nodes required to ensure the dataconsistency, and further improves the service availability at the sametime ensuring the data consistency.

BRIEF DESCRIPTION OF THE DRAWINGS

Other features, objects, and advantages of the present disclosure willbecome more apparent by reading the following detailed description ofnon-limiting embodiments with reference to the accompanying drawings:

FIG. 1 is an exemplary system architecture to which the method of thepresent disclosure may be applicable;

FIG. 2 is a flowchart of one embodiment of the data storage methodapplicable to a data server cluster according to the present disclosure;

FIG. 3 is a schematic diagram of the principle of the specificembodiment, as shown in FIG. 2, of the data storage method applicable toa data server cluster;

FIG. 4 is a flowchart of the data storage method applicable to a dataserver cluster according another embodiment of to the presentdisclosure;

FIG. 5 is a schematic diagram of the principle of the specificembodiment, as shown in FIG. 3, of the data storage method applicable toa data server cluster;

FIG. 6 is a structural schematic diagram of one embodiment of a datastorage server applicable to a data server cluster; and

FIG. 7 is a structural schematic diagram of a computer system adapted toimplement a server in a distributed server cluster according to theembodiments of the present disclosure.

DETAILED DESCRIPTION OF EMBODIMENTS

The present disclosure will be further described below in detail incombination with the accompanying drawings and the embodiments. Itshould be appreciated that the specific embodiments described herein aremerely used for explaining the relevant disclosure, rather than limitingthe disclosure. In addition, it should be noted that, for the ease ofdescription, only the parts related to the relevant disclosure are shownin the accompanying drawings.

It should also be noted that the embodiments in the present disclosureand the features in the embodiments may be combined with each other on anon-conflict basis. The present disclosure will be described below indetail with reference to the accompanying drawings and in combinationwith the embodiments.

FIG. 1 shows an exemplary architecture of a system 100 which may be usedby a data storage method according to the embodiments of the presentdisclosure.

As shown in FIG. 1, the system architecture 100 may include client 101,a network 102 and a distributed data server cluster 103. The network 102serves as a medium providing a communication link between the client 101and the server cluster 103 and between servers at different locations ofthe server cluster 103. The network 102 may include various types ofconnections, such as wired or wireless transmission links, or opticalfibers.

The user 110 may write data to or request to read data from thedistributed data server cluster 103 through the client 101. The client101 may be configured in a terminal device, such as a computer with adisplay screen. The user 110 inputs a data read/write request through aninput interface of the terminal device, and the terminal device sendsthe data read/write request to the distributed data server cluster 103.

Comprising a plurality of servers 1030, the distributed data servercluster 103 may be a server cluster that provides data services forapplications of the client 101, or, may be a server cluster thatprovides a data server for an online service. The plurality of servers1030 in the server cluster 103 may be in data centers located indifferent geographical locations, for example, the servers 1030 in theserver cluster 103 in FIG. 1 may be located in a Beijing computer room,a Shanghai computer room and a Guangzhou computer room, respectively.Each of the servers 1030 may be connected to each other through anetwork. The server cluster 103 may receive a data read/write requestsent by the user 110 through the client 101 and perform procession onthe data read/write request, for example, may update the data wrote bythe user to multiple servers, and then return a message of successfuldata write to the client.

It should be noted that, the data storage method applicable to the dataserver cluster provided by the embodiment of the present disclosure isgenerally executed by the server cluster 103, and the data storageserver applicable to the data server cluster is generally disposed inthe server cluster.

It should be understood that, the number of the clients, networks, andservers in the server cluster in FIG. 1 is merely illustrative.Depending on implementation requirements, there can be any number of theclients, the networks and the servers.

Further referring to FIG. 2, which shows a flowchart of one embodimentof the data storage method applicable to a data server cluster accordingto the present disclosure. Here, the data server cluster includes aplurality of nodes, and each of the nodes may be a server. The datastorage method applicable to the data server cluster comprises followingsteps.

At step 201, a master node in the server cluster receives a data writerequest.

In the present embodiment, the data server cluster may adopt adistributed storage schema, each of the nodes is deployed in differentgeographical locations, one master node and a plurality of slave nodesare included therein. The master node can handle all of the client-sideinteractions, synchronize the data wrote by the client to the slavenode, and read the data requested by the client from the slave nodes.The slave nodes can receive a log synchronization message or a heartbeatmessage sent by the master node, perform operations such as logsynchronization and data reading, and return a response message to themaster node. Generally, there is one master node and a plurality ofslave nodes included in one server cluster.

The master node can receive a data write request sent by the client. Thedata write request comprises a to-be-written data. Optionally, the datawrite request may further include a user identifier of the client, anequipment identifier of the client, a request time and the like, theuser identifier and the equipment identifier may be used to discriminateand verify the client permissions before writing the data.

In an actual service scenario, the data write request may be, forexample, a request for entering user information, including a requestfor changing a user name or password. The entry of the user informationmay be executed by the user on the client and is sent by the clientequipment to the master node in the server cluster. The master node canreceive the request through the network.

At step 202, the master node broadcasts the data write request to eachof the groups in the server cluster.

In order to ensure that data services are provided normally when anequipment fault or a network fault occurs to some nodes in the servercluster, the master node needs to synchronize the to-be-written data tosome slave nodes, to ensure the services availability. At the same time,all backups of a given data in the server cluster need to be modified tothe latest data values, to avoid data consistency issues.

In the present embodiment, the master node may broadcast the receiveddata write request to each of the groups in the server cluster.Specifically, after receiving the data write request, the master nodemay send a broadcast message, to notify the groups which haveestablished data communications with the master node to write the data.Each of the groups includes at least one node, the group in which themaster node is located may only include the master node or may includethe master node and at least one slave node, the other groups mayinclude one or more slave nodes, and at least one of the groups includesat least two nodes.

In the present embodiment, the master node can establish and maintaindata communications with more than a half of the groups in the servercluster. Further, the master node can establish and maintain datacommunication with each of the groups according to a configured dataconsistency protocol. In the data consistency protocol, if the masternode has established data communication with at least one of the slavenodes in each of more than a half of the groups, then it is consideredthat the server cluster can meet data consistency requirements. Themaster node can periodically send a heartbeat message to a slave node inthe group that established a data communication with the master node,after receiving the heartbeat message the slave node returns a responsemessage to the master node, after the master node receives the responsemessage, the data communication between the group in which the slavenode is located and the master node is determined to be normal.

The master node may broadcast the data write request to each of thegroups that maintain data communication with the master node, that is,broadcast the data write request to each of the slave nodes thatrespectively belong to more than a half of the groups and maintain datacommunication with the master node. If at least one of the slave nodesin a group has received the data write request, it may be determinedthat the group has received the data write request.

At step 203, in response to receiving the confirmation message fed backfrom more than a half of the groups, the master node sends anotification message of successful writing to the client sending thewrite request.

After receiving the data write request broadcasted by the master node,the each of the slave nodes that maintain data communications with themaster node may write the to-be-written data in the data write requestinto a memory and then return a confirmation message of successfulwriting to the master node, then it can be determined that the group inwhich the slave node is located has fed back a confirmation message tothe master node, that is, it can be determined that the group in whichthe slave node is located has been written successfully. Theconfirmation message here may be a message confirming that data has beenwritten successfully.

Specifically, when the master node is not included in a group, the groupfeeds back a confirmation message to the master node in response to atleast one of the nodes in the group successfully writing theto-be-written data to the memory. That is, for other groups other thanthe group including the master node, if at least one of the slave nodesin the group has successfully written the to-be-written data to thememory and has sent a confirmation message of successful writing, it isconsidered that the group has been successfully written with the data,or that the group has completed the data synchronization. After morethan a half of the groups have been successfully written with the dataor have completed the data synchronizations, it can be determined thatthe server cluster has been successfully written with the data and hasachieved the data consistency, and that when the node fault occurs thedata would not be lost, then, the master node can send the notificationmessage of successful writing to the client sending the data writerequest.

In some optional implementations of the present embodiment, if thenumber of the groups feeding back the confirmation message to the masternode does not exceed a half, it can be determined that abnormalsituations have occurred to the master node, the slave node, or thenetwork. In this case, the master node may send a notification messageof failed write to the client sending the data write request.

For the group including the master node, it may be defaulted that thegroup has been successfully written with the data, that is, it may bedetermined that the group has fed back a confirmation message to themaster node.

In some optional implementations of the present embodiment, if a groupincludes the master node, the group may feedback a confirmation messageto the master node in response to the master node successfully writingthe to-be-written data to the memory. In other words, the group in whichthe master node is located after the master node has successful writtenthe to-be-written data into the memory of the master node, then thegroup in which the master node is located is written successfully. Aparameter returned after the data is written into the memory of themaster node may be monitored by the master node, the parameter serves asthe above-mentioned feedback confirmation message. After the parameteris detected, it is determined that the group in which the master node islocated has been written successfully.

In some other optional implementations of the present embodiment, if agroup includes the master node, the group may feedback a confirmationmessage to the master node in response to the master node and at leastone of the slave nodes in the group successfully writing theto-be-written data into the memory. In other words, when the group inwhich the master node is located further includes at least one slavenode, after the master node and the at least one slave node havesuccessfully written the to-be-written data into the memory, then thegroup in which the master node is located is written successfully.Similarly, a parameter, returned after the data is written into thememory of the master node, can be monitored by the master node, theparameter serves as the above-mentioned fed-back confirmation message.After one of the slave nodes in the same group also has successfullywritten the to-be-written data into the memory and has fed back with aconfirmation message, that the group in which the master node is locatedhas been written successfully is determined. Therefore, at least one ofthe slave nodes in the group in which the master node is located isadded as a data synchronization node, so that the data consistency ofthe data server cluster can be enhanced.

In the above embodiment, after more than a half of the groups aresuccessfully written, it may be determined that the data server clusterhas successfully completed the writing of the to-be-written data. Then,the master node may send a notification message to the client sendingthe data write request, to inform the client that the data write requesthas been processed and successfully written. The client may receive thenotification message and present it to the user.

Through the steps: a master node in a server cluster receives a datawrite request; and then the master node broadcasts the data writerequest to each of the groups in the server cluster, and sends anotification message to the client sending a data write request inresponse to receiving the confirmation message fed back by more than ahalf of the groups; there, in response to at least one of the nodes inthe group writing the to-be-written data into the memory, the groupswithout the master node included feed back the above confirmationmessage to the master node, and, at least one of the groups includes atleast two nodes, and by utilizing the method of data consistency amonggroups, may ensure that at least one of the nodes in each group has beenwritten with the to-be-written data. The data storage method applicableto a distributed server cluster provided in the above embodiments of thepresent disclosure, compared with the traditional distributed datastorage method which needs to synchronize the to-be-written data to morethan a half of nodes, reduces the number of the nodes needs to besynchronized with the data, increases the allowed number of faultynodes, thereby improves the service availability.

In some optional implementations of the present embodiment, the abovemethod may further includes: dividing a plurality of nodes in the servercluster into multiple groups, according to a deployed physical locationof each of the nodes. For example, as shown in the schema of FIG. 1,dividing according to the computer room in which each of the nodeslocated, the nodes in one computer room belonging to one group.

Further, the number of the nodes in a single group is less than a halfof the total number of the nodes in the server cluster, therefore, thecases that data is inconsistent or service is unavailable can be avoidedwhen fault occurs to the single computer room.

In some optional implementations of the present embodiment, the abovedata storage method may further includes: the master node sends a datasynchronization confirmation message to each of the groups feeding backthe confirmation message in response to receiving the confirmationmessage fed back from more than a half of the groups. In other words,after receiving the confirmation message fed back from more than a halfof the groups, the master node may send the data synchronizationconfirmation message to each of the groups feeding back the confirmationmessage. Specifically, the master node may send the data synchronizationconfirmation message to the slave nodes feeding back the confirmationmessage in each group, to complete the confirmation of the datasynchronization.

According to the data storage method provided in the above embodiment,the data server cluster performs data storage according to the followinggroup-based data consistency protocol: the master node needs to maintaindata communications with more than a half of the groups, and when atleast one of the nodes in a group maintains data communication with themaster node, it is considered that this group has maintained the datacommunication with the master node.

Referring to FIG. 3, which shows a schematic diagram of the principle ofthe specific embodiment, as shown in FIG. 2, of the data storage methodapplicable to a data server cluster, which also shows a schematicdiagram of an application scenario of the data storage of the abovegroup-based data consistency protocol of a server cluster.

As shown in FIG. 3, the data server cluster includes total five groups:group 1, group 2, group 3, group 4, and group 5, and each of the groupscan be located in different computer rooms. The group 1 includes themaster node M and one slave node S1, the group 2 includes three slavenodes S2, S3 and S4, the group 3 includes one slave node S5, the group 4includes two slave nodes S6 and S7, and the group 5 includes two slavenodes S8 and S9. The master node M maintains data communication with theslave node S4 in the group 2 and the slave node S7 in group 4. When datais written, the master node M receives a confirmation message “OK” fedback from the master node M of the group 1, the slave node S4 in thegroup 2 and the slave node S7 in the group 4, and then, may send anotification message “OK” of successful writing to client C. Or, themaster node M receives the confirmation message “OK” fed back from themaster node M and the slave node S1 in the group 1, the slave node S4 inthe group 2 and the slave node S7 in the group 4, and then, the masternode M may send a notification message “OK” of successful writing. Here,the master node M maintains data communication with the group 1, thegroup 2 and the group 4, so as to ensure that the data of the masternode M may be backed up across the computer rooms in real time, and thedata of the service will not be lost and remains consistent amongmultiple nodes.

It can be seen from FIG. 3 that in the application scenario of thepresent embodiment, the number of the nodes that maintain communicationwith the master node is less than a half of the total number of thenodes in the server cluster. When fault occurs to some nodes in theserver cluster, fewer nodes are utilized to ensure the data consistencyand thus to avoid the cases that the service availability is greatlyaffected.

Referring to FIG. 4, which shows a flowchart of the data storage methodapplicable to a data server cluster according to another embodiment ofthe present disclosure, the data storage method applicable to the dataserver cluster comprises following steps.

At step 401, the master node in the server cluster receives a data writerequest.

In the present embodiment, the data server cluster may adopt adistributed storage schema, each of the nodes is deployed in differentgeographical locations, and one master node and a plurality of slavenodes are included therein. The master node may receive a data writerequest sent by a client. The data write request includes to-be-writtendata. Optionally, the data write request may further comprises a useridentifier of the client, an equipment identifier of the client, arequest time and the like, the user identifier and the equipmentidentifier may be used to discriminate and verify the client permissionsbefore writing the data.

At step 402, the master node broadcasts the data write request to eachof the groups in the server cluster.

In the present embodiment, after receiving the data write request, themaster node broadcasts this data write request in the server cluster andrequests the other nodes to back up the to-be-written data. The groupswhich have established data communications with the master node mayreceive this data write request. Here, each of the groups includes atleast one node, the group in which the master node is located may onlyinclude the master node or may include the master node and at least oneslave node, the other groups may include one or more slave nodes, and atleast one of the groups includes at least two nodes.

In the present embodiment, the master node may establish and maintaindata communications with more than a half of the groups in the servercluster. Further, the master node may establish and maintain datacommunication with each of the groups according to a configured dataconsistency protocol. In the data consistency protocol, if the masternode has established data communication with at least one of the slavenodes in each of more than a half of the groups, then it may beconsidered that the server cluster meet data consistency requirements.

At step 403, the master node sends a notification message of successfulwriting to the client sending the data write request, in response toreceiving a confirmation message fed back from more than a half of thegroups.

After receiving the data write request broadcasted by the master node,each of the slave nodes that maintains data communication with themaster node may write the to-be-written data in the data write requestinto a memory and then returns a confirmation message of successfulwriting to the master node, then it can be determined that the group inwhich the slave node is located has fed back the confirmation message tothe master node, that is, it can be determined that the group in whichthe slave node is located has been written successfully.

When the master node is not included in a group, the group feeds back aconfirmation message to the master node in response to at least one ofthe nodes in the group successfully writing the to-be-written data tothe memory. That is, for other groups other than the group including themaster node, if at least one of the slave nodes in the group hassuccessfully written the to-be-written data to the memory and has sent aconfirmation message of successful writing, it is considered that thegroup has been successfully written with the data, or that the group hascompleted the backup of the data. Then, the master node may send anotification message of successful writing to the client sending thedata write request.

If a group includes the master node: in some optional implementations,the group may feedback a confirmation message to the master node inresponse to the master node and at least one of the slave nodes in thegroup successfully writing the to-be-written data into the memory; insome other optional implementations, the group may feedback aconfirmation message to the master node in response to the master nodesuccessfully writing the to-be-written data to the memory. In otherwords, the group in which the master node is located may feedback with aconfirmation message after the master node has written the datasuccessfully, may feed back a confirmation message after the master nodeand at least one of the slave nodes have written the data successfully.

In some optional implementations of the present embodiment, if thenumber of the groups feeding back the confirmation message to the masternode does not exceed a half, it may be determined that abnormalsituations have occurred to the master node, the slave node or thenetwork. In this case, the master node may send a notification messageof failed write to the client sending the data write request.

At step 404, a slave node in the server cluster as a candidate nodeissues an election request to each of the groups, in response to thenumber of the groups feeding back the confirmation message to the masternode being less than a half, or that none of the nodes in each of morethan a half groups receive the heartbeat message broadcasted by themaster node within a preset time.

In the present embodiment, when the number of the groups feeding backthe confirmation message to the master node is less than a half, or thatnone of the nodes in each of more than a half groups receive theheartbeat message broadcasted by the master node within a preset time,it can be determined that the number of the groups maintainingcommunication with the master node is less than a half, then, to ensurethe data consistency, a slave node in the server cluster becomes thecandidate node and issues an election request to each of the groups.

According to one aspect, specifically, if the number of the groupsfeeding back a confirmation message to the master node does not exceed ahalf, then it is determined that the number of the groups maintainingdata communication with the mater node does not exceed a half, and thebackup and the consistency of the data cannot be ensured, and then theother slave nodes may issue an election request.

According to another aspect, the data communications between the masternode and the slave nodes of each of the groups are maintained throughthe heartbeat message sent by the master node. Each of the slave node isconfigured with a clock which issues the election, within a preset timeof the clock the slave node would not issue the election request. Afterreceiving the heartbeat message sent by the master node, the clock ofthe slave node is reset and timing is restarted. If the slave node doesnot receive the heartbeat message sent by the master node within apreset time, then the slave node is triggered to issue an electionrequest to the other nodes.

At step 405, the candidate node is switched as a new master node, inresponse to the candidate node receiving the agree message fed back fromeach node in each of more than a half of the groups.

The moment a slave node issues the election request the slave nodebecomes the candidate node. In the present embodiment, the other nodesin the server cluster may send an agree message or a rejection messageto the candidate node after receiving the election request. If thecandidate node receives the agree message from each node in the each ofmore than a half groups, then the candidate node is switched as themaster node and the original master node is switched as a slave node. Inother words, if each node in more than a half of the groups votes forthe candidate node, the candidate node becomes the new master node.

According to the above data storage method 400, the data server clusterelects the master node based on following group-based consistencyprotocol: if a node receives the a vote from each node of more than ahalf of the groups, the node becomes the new master node.

The step 401, step 402 and step 403 in the above method flowchart isidentical with the step 201, the step 202 and the step 205 in the abovedescribed embodiments, the above descriptions on the step 201, the step202 and the step 205 also apply to the step 401, step 402 and step 403in the present embodiment and will not be repeated here.

It can be seen that, based on the embodiment shown in FIG. 2, theembodiment shown in FIG. 4 adds the strategy of electing a new masternode when fault occurs to the master node or the network, that is, afterone of the nodes becomes a candidate node and gains a vote from eachnode in each of the most of the groups, the candidate node is switchedas a new master node. Therefore, when abnormal situations in theequipment or the network caused the data communication between themaster node and the group disconnected, the data storage method 400applicable to the distributed server cluster of the present embodimentmay switch the master node in time, to ensure the reliability of thedata backup.

Referring to FIG. 5, which shows the schematic diagram of the principleof the specific embodiment, as shown in FIG. 3, of the data storagemethod applicable to a data server cluster, which also shows theschematic diagram of a master election application scenario of the datastorage of the above group-based data consistency protocol of a servercluster.

As shown in FIG. 5, the distributed data server cluster includes ninenodes: M(S0), S1, S2, S3, S4, S5, S6, S7(M′), S8, and S9, the nodes aredivided into five groups, wherein the group 1 includes nodes M and S1,the group 2 includes nodes S2, S3 and S4, the group 3 includes nodes S5,the group 4 includes nodes S6 and S7, and group 5 includes nodes S8 andS9. When fault occurs to the group 1 (for example, an abnormal situationoccurs to the network of the computer room corresponding to the group1), the master node M cannot maintain the data communication with morethan a half of the groups in the server cluster. Then the node S7 mayissue an election and send the election request to the other node S6 inthe same group, as well as the other groups. After each node in each ofmore than a half of the groups, including the node S7, confirms the votefor the node S7, the node S7 is switched as the new master node. Forexample, in FIG. 5, all the nodes in the total four groups, which arethe group 2, the group 3, the group 5 and the group in which the node S7located, confirm the votes for the node S7, by now the number of thegroups, all nodes in which have voted, exceeds a half, then the node S7is switched as the master node M′.

Further referring to FIG. 6, as an implementation of the method shown inthe above figures, the present disclosure provides an embodimentapplicable to the data storage sever in the distributed sever cluster.

As shown in FIG. 6, the data storage server 600 applicable to adistributed server cluster of the present embodiment includes: areceiving unit 601, a broadcasting unit 602 and a sending unit 603.Here, the receiving unit 601 is used for receiving a data write request,the data write request comprising to-be-written data; the broadcastingunit 602 is used for broadcasting the data write request to each of thegroups in the server cluster, the each of the groups including at leastone node, and at least one of the groups including at least two nodes;the sending unit 603 is used for sending a notification message ofsuccessful writing to a client sending the data write request, inresponse to receiving a confirmation message fed back from more than ahalf of the groups; wherein, if the group does not include a master nodein the server cluster, the group feeds back the confirmation message tothe master node, in response to at least one of the nodes in the groupwriting the to-be-written data to a memory successfully.

In the present embodiment, when the above server 600 is the master nodein the server cluster, the receiving unit 601 may receive the data writerequest from a client, the data write request may include a useridentifier, an equipment identifier of the client, a request time andthe like, other than the to-be-written data. The broadcasting unit 602may broadcast the data write request received from the receiving unit601 to each of the groups in the server cluster, to notify each of thegroups to back up the data. The server in the groups in communicationconnection with a master server may receive he message broadcasted bythe broadcasting unit 602. When at least one of the nodes in each of thegroups in more than a half of the groups has fed back with theconfirmation message, the sending unit 603 may determine that the datahas been written into more than a half of the groups, then, anotification message may be sent to the client, to notify the clientthat the data has been successfully written.

In some embodiments, if a group includes the master node, the group inwhich the master node is located feeds back a confirmation message tothe master node in response to the master node writing the to-be-writtendata into the memory successfully. In some other embodiments, if a groupincludes the master node and at least one slave node, the group in whichthe master node is located feeds back a confirmation message to themaster node in response to the master node and at least one of the slavenodes in the group writing the to-be-written data into the memorysuccessfully.

In some embodiment, the above server 600 may further include: arequesting unit and a switching unit. When a server is a slave node inthe server cluster, the requesting unit as a candidate node issues anelection request to each of the groups, in response to a number of thegroups feeding back the confirmation message to the master node beingless than a half, or none of the nodes in each of more than a half ofthe groups receiving a heartbeat message broadcasted by the master nodewithin a preset time; the switching unit is configured to be switched asa new master node, in response to the candidate node receiving an agreemessage from each node in the each of more than a half of the groups.

In some embodiments, the above server may further include a confirmationunit, configured to send a data synchronization confirmation message tothe each of the groups feeding back the confirmation message in responseto receiving the confirmation message fed back from more than a half ofthe groups.

It should be understood that, the units recorded in the server 600 iscorresponding to each of the steps of the method described withreference to the FIG. 2 and FIG. 4. Therefore, the above describedoperations and characteristics on the method is also adapted to theserver 600 as well as the units included therein, which will not berepeated here.

The storage server 600 applicable to the distributed data server clusterand provided in the embodiments of the present disclosure, as the masternode in the server cluster, may receive the data write request sent formthe client, broadcast the data write request to multiple groups in theserver cluster, and send a notification message of successful writing tothe client when receiving the confirmation message fed back from atleast one of the nodes in more than a half groups, which may decreasethe number of nodes required to ensure the data consistency, and furtherimprove the service availability with the data consistency.

Further referring to FIG. 7, which shows a structural schematic diagramof a computer system adapted to implement a server in a distributedserver cluster according to an embodiment of the present disclosure. Theserver shown in FIG. 7 is merely an example and should not bring anylimitation to the function and usage range of the embodiments of thepresent disclosure.

As shown in FIG. 7, the computer system 700 includes a centralprocessing unit (CPU) 701, which may execute various appropriate actionsand processes in accordance with a program stored in a read-only memory(ROM) 702 or a program loaded into a random access memory (RAM) 703 froma storage portion 708. The RAM 703 also stores various programs and datarequired by operations of the system 700. The CPU 701, the ROM 702 andthe RAM 703 are connected to each other through a bus 704. Aninput/output (I/O) interface 705 is also connected to the bus 704.

The following components are connected to the I/O interface 705: aninput portion 706 including a keyboard, a mouse etc.; an output portion707 comprising a cathode ray tube (CRT), a liquid crystal display device(LCD), a speaker etc.; a storage portion 708 including a hard disk andthe like; and a communication portion 709 comprising a network interfacecard, such as a LAN card and a modem. The communication portion 709performs communication processes via a network, such as the Internet. Adriver 710 is also connected to the I/O interface 705 as required. Aremovable medium 711, such as a magnetic disk, an optical disk, amagneto-optical disk, and a semiconductor memory, may be installed onthe driver 710, to facilitate the retrieval of a computer program fromthe removable medium 711, and the installation thereof on the storageportion 708 as needed.

In particular, according to embodiments of the present disclosure, theprocess described above with reference to the flow chart may beimplemented in a computer software program. For example, an embodimentof the present disclosure includes a computer program product, whichcomprises a computer program that is tangibly embedded in amachine-readable medium. The computer program comprises program codesfor executing the method as illustrated in the flow chart. In such anembodiment, the computer program may be downloaded and installed from anetwork via the communication portion X09, and/or may be installed fromthe removable media X11. The computer program, when executed by thecentral processing unit (CPU) X01, implements the above mentionedfunctionalities as defined by the methods of the present disclosure. Itshould be noted that the computer readable medium in the presentdisclosure may be computer readable signal medium or computer readablestorage medium or any combination of the above two. An example of thecomputer readable storage medium may include, but not limited to:electric, magnetic, optical, electromagnetic, infrared, or semiconductorsystems, apparatus, elements, or a combination any of the above. A morespecific example of the computer readable storage medium may include butis not limited to: electrical connection with one or more wire, aportable computer disk, a hard disk, a random access memory (RAM), aread only memory (ROM), an erasable programmable read only memory (EPROMor flash memory), a fibre, a portable compact disk read only memory(CD-ROM), an optical memory, a magnet memory or any suitable combinationof the above. In the present disclosure, the computer readable storagemedium may be any physical medium containing or storing programs whichcan be used by a command execution system, apparatus or element orincorporated thereto. In the present disclosure, the computer readablesignal medium may include data signal in the base band or propagating asparts of a carrier, in which computer readable program codes arecarried. The propagating signal may take various forms, including butnot limited to: an electromagnetic signal, an optical signal or anysuitable combination of the above. The signal medium that can be read bycomputer may be any computer readable medium except for the computerreadable storage medium. The computer readable medium is capable oftransmitting, propagating or transferring programs for use by, or usedin combination with, a command execution system, apparatus or element.The program codes contained on the computer readable medium may betransmitted with any suitable medium including but not limited to:wireless, wired, optical cable, RF medium etc., or any suitablecombination of the above.

The flow charts and block diagrams in the accompanying drawingsillustrate architectures, functions and operations that may beimplemented according to the systems, methods and computer programproducts of the various embodiments of the present disclosure. In thisregard, each of the blocks in the flow charts or block diagrams mayrepresent a module, a program segment, or a code portion, said module,program segment, or code portion comprising one or more executableinstructions for implementing specified logic functions. It should alsobe noted that, in some alternative implementations, the functionsdenoted by the blocks may occur in a sequence different from thesequences shown in the figures. For example, any two blocks presented insuccession may be executed, substantially in parallel, or they maysometimes be in a reverse sequence, depending on the function involved.It should also be noted that each block in the block diagrams and/orflow charts as well as a combination of blocks may be implemented usinga dedicated hardware-based system executing specified functions oroperations, or by a combination of a dedicated hardware and computerinstructions.

The units or modules involved in the embodiments of the presentdisclosure may be implemented by means of software or hardware. Thedescribed units or modules may also be provided in a processor, forexample, described as: a processor, comprising a receiving unit, abroadcasting unit and a sending unit, where the names of these units ormodules do not in some cases constitute a limitation to such units ormodules themselves. For example, the receiving unit may also bedescribed as “a unit for receiving a data write request.”

In another aspect, the present disclosure further provides acomputer-readable storage medium. The computer-readable storage mediummay be the computer storage medium included in the apparatus in theabove described embodiments, or a stand-alone computer-readable storagemedium not assembled into the apparatus. The computer-readable storagemedium stores one or more programs. The one or more programs, whenexecuted by a device, cause the device to: receive a data write request,the data write request comprising the to-be-written data; broadcast thedata write request to each of the groups in the server cluster, the eachof the groups comprising at least one node, and at least one of thegroups comprising at least two nodes; and send a notification message ofsuccessful writing to a client sending the data write request, inresponse to receiving a confirmation message fed back from more than ahalf of the groups; wherein, if the group does not comprise a masternode in the server cluster, the group feeds back the confirmationmessage to the master node, in response to at least one of the nodes inthe group writing the to-be-written data to a memory successfully.

The above description only provides an explanation of the preferredembodiments of the present disclosure and the technical principles used.It should be appreciated by those skilled in the art that the inventivescope of the present disclosure is not limited to the technicalsolutions formed by the particular combinations of the above-describedtechnical features. The inventive scope should also cover othertechnical solutions formed by any combinations of the above-describedtechnical features or equivalent features thereof without departing fromthe concept of the disclosure. Technical schemes formed by theabove-described features being interchanged with, but not limited to,technical features with similar functions disclosed in the presentdisclosure are examples.

What is claimed is:
 1. A data storage method applicable to a distributedserver cluster, the distributed server cluster comprising a plurality ofnodes, including a master node and a plurality of slave nodes, and themethod comprising: forming a plurality of groups according to a deployedphysical location of each of the plurality of nodes that are included inthe distributed server cluster such that nodes of the plurality of nodesdeployed in a same physical location belong to a same group, wherein theplurality of groups comprises a first group comprising at least saidmaster node, a plurality of second groups each comprising at least twoslave nodes but not comprising said master node, and a third groupcomprising at least one slave node but not comprising said master node;receiving, by the master node in the distributed server cluster, a datawrite request, the data write request comprising to-be-written data;broadcasting, by the master node, the data write request to each of theplurality of groups in the distributed server cluster; and sending, bythe master node, a notification message of successful writing to aclient sending the data write request, in response to receivingconfirmation messages of successfully writing the to-be-written data inmemory fed back from more than a half of the plurality of groups;wherein, for the first group comprising the master node, the group feedsback the confirmation message to the master node in response to themaster node writing the to-be-written data to a memory successfully;wherein, each of the plurality of second groups not comprising saidmaster node and the third group not comprising said master node feedsback the confirmation message to the master node in response to at leastone node in respective group writing the to-be-written data to a memorysuccessfully.
 2. The data storage method according to claim 1, wherein,for a group comprising the master node and at least one slave node, thegroup feeds back the confirmation message to the master node in responseto the master node and at least one of the at least one slave node inthe group writing the to-be-written data to the memory successfully. 3.The data storage method according to claim 1, further comprising:issuing, by one of the plurality of slave nodes in the distributedserver cluster as a candidate node, an election request to each of theplurality of groups, in response to a number of the plurality of groupsfeeding back the confirmation message to the master node being less thana half, or none of the plurality of slave nodes in each of more than ahalf of the plurality of groups receiving a heartbeat messagebroadcasted by the master node within a preset time; and switching thecandidate node as a new master node, in response to the candidate nodereceiving an agree message from each of the plurality of slave nodes inthe each of more than a half of the plurality of groups.
 4. The datastorage method according to claim 1, further comprising: sending, by themaster node, a data synchronization confirmation message to the each ofthe plurality of groups feeding back the confirmation message, inresponse to receiving the confirmation message fed back from more than ahalf of the plurality of groups.
 5. A data storage server applicable toa distributed server cluster comprising a plurality of nodes, includinga master node and a plurality of slave nodes, comprising: at least oneprocessor; and a memory storing instructions, which when executed by theat least one processor, cause the at least one processor to performoperations, the operations comprising: forming a plurality of groupsaccording to a deployed physical location of each of the plurality ofnodes that are included in the distributed server cluster such thatnodes of the plurality of nodes deployed in a same physical locationbelong to a same group, wherein the plurality of groups comprises afirst group comprising at least said master node, a plurality of secondgroups each comprising at least two slave nodes but not comprising saidmaster node, and a third group comprising at least one slave node butnot comprising said master node; receiving a data write request, thedata write request comprising to-be-written data; broadcasting the datawrite request to each of the plurality of groups in the distributedserver cluster; and sending a notification message of successful writingto a client sending the data write request, in response to receivingconfirmation messages of successfully writing the to-be-written data inmemory fed back from more than a half of the plurality of groups;wherein, for the first group comprising the master node, the group feedsback the confirmation message to the master node in response to themaster node writing the to-be-written data to a memory successfully;wherein, each of the plurality of second groups not comprising saidmaster node and the third group not comprising a master node in thedistributed server cluster feeds back the confirmation message to themaster node in response to at least one node in respective group writingthe to-be-written data to a memory successfully.
 6. The data storageserver according to claim 5, wherein the operations further comprise:issuing, by one of the plurality of slave nodes in the distributedserver cluster as a candidate node, an election request to each of theplurality of groups, in response to a number of the plurality of groupsfeeding back the confirmation message to the master node being less thana half, or none of the plurality of slave nodes in each of more than ahalf of the plurality of groups receiving a heartbeat messagebroadcasted by the master node within a preset time; and switching thecandidate node as a new master node, in response to the candidate nodereceiving an agree message from each of the plurality of slave nodes inthe each of more than a half of the plurality of groups.
 7. The datastorage server according to claim 5, wherein the operations furthercomprise: sending a data synchronization confirmation message to theeach of the plurality of groups feeding back the confirmation message,in response to receiving the confirmation message fed back from morethan a half of the plurality of groups.
 8. A non-transitorycomputer-readable storage medium, storing a computer program thereon,wherein the program, when executed by a processor, causes the processorto perform operations, the operations comprising: forming a plurality ofgroups according to a deployed physical location of each of a pluralityof nodes including a master node and a plurality of slave nodes that areincluded in a distributed server cluster such that nodes of theplurality of nodes deployed in a same physical location belong to a samegroup, wherein the plurality of groups comprises a first groupcomprising at least said master node, a plurality of second groups eachcomprising at least two of the plurality of slave nodes but notcomprising said master node, and a third group comprising at least oneof the plurality of slave nodes but not comprising said master node;receiving, by the master node in the distributed server cluster, a datawrite request, the data write request comprising to-be-written data;broadcasting, by the master node, the data write request to each of theplurality of groups in the distributed server cluster; and sending, bythe master node, a notification message of successful writing to aclient sending the data write request, in response to receivingconfirmation messages of successfully writing the to-b-written data inmemory fed back from more than a half of the plurality of groups;wherein, for the first group comprising the master node, the group feedsback the confirmation message to the master node in response to themaster node writing the to-be-written data to a memory successfully;wherein, each of the plurality of second groups not comprising saidmaster node and the third group not comprising said master node feedsback the confirmation message to the master node in response to at leastone node in respective group writing the to-be-written data to a memorysuccessfully.